const path = require('path');
const extractTextWebpackPlugin = require('extract-text-webpack-plugin');
const webpackConfig = {
    entry: {
        app: './src/app.js'
    },
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: '[name].bundle.js',
        publicPath: ''
    },
    module: {
        rules: [{
            test: /\.css$/,
            use: extractTextWebpackPlugin.extract({
                fallback: {
                    loader: 'style-loader',
                    options: {
                        singleton: true
                    }
                },
                use: [{
                    loader: 'css-loader',
                    options: {
                        minimize: true
                    }
                }]
            })
        }, {
            test: /\.(png|jpg|jpeg|gif)$/,
            // use: [{
            //     loader: 'file-loader',
            //     options: {
            //         name: '[name].[ext]',
            //         outputPath: 'img/'
            //     }
            // }]
            use: [{
                loader: 'url-loader',
                options: {
                    name: '[name].[ext]',
                    outputPath: 'img/',
                    limit: 30000
                }
            }]
        }]
    },
    plugins: [
        new extractTextWebpackPlugin({
            filename: '[name].min.css',
            allChunks: true
        })
    ]
};
module.exports = webpackConfig;